<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .ac {
            width: 50px;
            height: 50px;
            background: lightgreen;
            list-style: none;
        }
    </style>
</head>

<body>
    <ul>
        <li class="ac">1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
    </ul>
    <script>
        var ali = document.getElementsByTagName('li');
        for (var index = 0; index < ali.length; index++) {
            ali[index].onclick = function () {
                for (var j = 0; j < ali.length; j++) {
                    ali[j].className = '';
                }
                this.className = 'ac';
            }
        }
    </script>
</body>

</html>